﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ZK.YHP_TransManage
{

  
    public partial class @lock : Form
    {
        static readonly object obj = new object();
        public @lock()
        {
            InitializeComponent();
        }

        private async  void  button1_Click(object sender, EventArgs e)
        {
            await Task.Run(() => {
                lock (obj)
                {
                    Thread.Sleep(1000000);
                }
            });
            
        }
      
        private void button3_Click(object sender, EventArgs e)
        {
           bool a =  Monitor.TryEnter(obj);
        }
       
    }
}
